/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.facilscrum.form.issues;

import org.facilscrum.beans.Equiposusuarios;
import org.facilscrum.beans.Estatus;
import org.facilscrum.beans.Issues;
import org.facilscrum.beans.Prioridad;
import org.facilscrum.beans.Tipo;
import org.facilscrum.beans.Usuarios;
import org.facilscrum.controller.EquiposusuariosController;
import org.facilscrum.controller.EstatusController;
import org.facilscrum.controller.IssuesController;
import org.facilscrum.controller.PrioridadController;
import org.facilscrum.controller.TipoController;
import org.facilscrum.controller.UsuariosController;
import org.facilscrum.generales.Mensajeria;
import org.facilscrum.sesion.MySesion;

/**
 *
 * @author avbravo
 */
public class IssuesForm extends javax.swing.JInternalFrame {

    EquiposusuariosController equiposusuariosController = new EquiposusuariosController();
    Estatus estatus = new Estatus();
    EstatusController estatusController = new EstatusController();
    Issues issues = new Issues();
    IssuesController issuesController = new IssuesController();
    Prioridad prioridad = new Prioridad();
    PrioridadController prioridadController = new PrioridadController();
    Tipo tipo = new Tipo();
    TipoController tipoController = new TipoController();
    UsuariosController usuariosController = new UsuariosController();
    Usuarios usuarios = new Usuarios();

    /**
     * Creates new form UsuariosForm
     */
    public IssuesForm() {
        initComponents();
        jButtonAgregar.setEnabled(false);
        if (!MySesion.getSeleccionoProyectoTrabajo()) {
            Mensajeria.MensajeWarning("Debe indicar el proyecto de trabajo");
        } else {
            if (cargarPrioridad() && cargarTipo() && cargarUsuarios() && cargarReporta()) {
                String sql = "esinicial='si'";
                if (estatusController.count(sql) != 1) {
                    Mensajeria.MensajeWarning("Debe indicar un estatus inicial\nMenu Tools->Estatus");
                } else {
                    if (estatusController.query(sql)) {
                        estatus = estatusController.getEstatuslist().get(0);
                        jLabelEstatus.setText(estatus.getEstatus());
                    }
                    jButtonAgregar.setEnabled(true);
                }

            } else {
                jTextFieldTitulo.setEnabled(false);
                jButtonLimpiar.setEnabled(false);
            }
            jTextFieldProyecto.setText(MySesion.getProyectos().getProyecto());
        }

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupAsignado = new javax.swing.ButtonGroup();
        buttonGroupQuienReporte = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldTitulo = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jComboBoxTipo = new javax.swing.JComboBox();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextAreaDescripcion = new javax.swing.JTextArea();
        jComboBoxPrioridad = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldProyecto = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabelEstatus = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jCheckBoxNoAsignado = new javax.swing.JCheckBox();
        jCheckBoxSiAsignado = new javax.swing.JCheckBox();
        jComboBoxAsignado = new javax.swing.JComboBox();
        jButtonLimpiar = new javax.swing.JButton();
        jButtonAgregar = new javax.swing.JButton();
        jButtonCerrar = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jCheckBoxYoReporta = new javax.swing.JCheckBox();
        jCheckBoxOtroReporta = new javax.swing.JCheckBox();
        jComboBoxReporta = new javax.swing.JComboBox();

        setClosable(true);
        setTitle("Issues");
        setToolTipText("");

        jLabel1.setText("Titulo");

        jTextFieldTitulo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldTituloActionPerformed(evt);
            }
        });

        jLabel2.setText("Descripcion");

        jLabel4.setText("Tipo");

        jLabel5.setText("Prioridad");

        jTextAreaDescripcion.setColumns(20);
        jTextAreaDescripcion.setRows(5);
        jScrollPane2.setViewportView(jTextAreaDescripcion);

        jLabel3.setText("Proyecto");

        jTextFieldProyecto.setEnabled(false);

        jLabel6.setText("Estatus");

        jLabelEstatus.setText("...");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Tiene asignado un tecnico"));

        buttonGroupAsignado.add(jCheckBoxNoAsignado);
        jCheckBoxNoAsignado.setSelected(true);
        jCheckBoxNoAsignado.setText("No");
        jCheckBoxNoAsignado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxNoAsignadoActionPerformed(evt);
            }
        });

        buttonGroupAsignado.add(jCheckBoxSiAsignado);
        jCheckBoxSiAsignado.setText("Si");
        jCheckBoxSiAsignado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxSiAsignadoActionPerformed(evt);
            }
        });

        jComboBoxAsignado.setEnabled(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jCheckBoxNoAsignado)
                .addGap(18, 18, 18)
                .addComponent(jCheckBoxSiAsignado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jComboBoxAsignado, javax.swing.GroupLayout.PREFERRED_SIZE, 359, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBoxNoAsignado)
                    .addComponent(jCheckBoxSiAsignado)
                    .addComponent(jComboBoxAsignado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(33, Short.MAX_VALUE))
        );

        jButtonLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/clear.png"))); // NOI18N
        jButtonLimpiar.setToolTipText("Limpiar");
        jButtonLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimpiarActionPerformed(evt);
            }
        });

        jButtonAgregar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/save_icon.gif"))); // NOI18N
        jButtonAgregar.setToolTipText("Agregar");
        jButtonAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAgregarActionPerformed(evt);
            }
        });

        jButtonCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/return.gif"))); // NOI18N
        jButtonCerrar.setToolTipText("Cerrar");
        jButtonCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCerrarActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Quien reporta el issues"));

        buttonGroupQuienReporte.add(jCheckBoxYoReporta);
        jCheckBoxYoReporta.setSelected(true);
        jCheckBoxYoReporta.setText("Yo");
        jCheckBoxYoReporta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxYoReportaActionPerformed(evt);
            }
        });

        buttonGroupQuienReporte.add(jCheckBoxOtroReporta);
        jCheckBoxOtroReporta.setText("Otro");
        jCheckBoxOtroReporta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxOtroReportaActionPerformed(evt);
            }
        });

        jComboBoxReporta.setEnabled(false);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jCheckBoxYoReporta)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBoxOtroReporta)
                .addGap(18, 18, 18)
                .addComponent(jComboBoxReporta, javax.swing.GroupLayout.PREFERRED_SIZE, 359, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBoxYoReporta)
                    .addComponent(jCheckBoxOtroReporta)
                    .addComponent(jComboBoxReporta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 8, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel1))
                                .addGap(45, 45, 45)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldProyecto)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jComboBoxTipo, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jTextFieldTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 425, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jComboBoxPrioridad, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabelEstatus, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(0, 193, Short.MAX_VALUE))))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(151, 151, 151)
                                .addComponent(jButtonAgregar, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jButtonLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButtonCerrar, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel6))
                                .addGap(314, 314, 314)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(2, 2, 2)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(jLabel2))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jComboBoxTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jComboBoxPrioridad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabelEstatus))
                .addGap(28, 28, 28)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonLimpiar)
                    .addComponent(jButtonAgregar)
                    .addComponent(jButtonCerrar))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 6, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAgregarActionPerformed
        try {
            if (!guiToData()) {
                return;
            }
            if (issuesController.insert(issues)) {
                Mensajeria.Mensaje("Se guardo exitosamente");
                limpiar();
                
            } else {
                Mensajeria.MensajeWarning("No se pudo guardar " + issuesController.getMensaje());
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "agregar()");
        }
    }//GEN-LAST:event_jButtonAgregarActionPerformed

    private void jButtonLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimpiarActionPerformed
        limpiar();

    }//GEN-LAST:event_jButtonLimpiarActionPerformed

    private void jButtonCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCerrarActionPerformed
        dispose();
    }//GEN-LAST:event_jButtonCerrarActionPerformed

    private void jTextFieldTituloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldTituloActionPerformed
    }//GEN-LAST:event_jTextFieldTituloActionPerformed

    private void jCheckBoxNoAsignadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxNoAsignadoActionPerformed
        jComboBoxAsignado.setEnabled(false);
    }//GEN-LAST:event_jCheckBoxNoAsignadoActionPerformed

    private void jCheckBoxSiAsignadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxSiAsignadoActionPerformed
        jComboBoxAsignado.setEnabled(true);
    }//GEN-LAST:event_jCheckBoxSiAsignadoActionPerformed

    private void jCheckBoxOtroReportaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxOtroReportaActionPerformed
        jComboBoxReporta.setEnabled(true);
    }//GEN-LAST:event_jCheckBoxOtroReportaActionPerformed

    private void jCheckBoxYoReportaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxYoReportaActionPerformed
        jComboBoxReporta.setEnabled(false);
    }//GEN-LAST:event_jCheckBoxYoReportaActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroupAsignado;
    private javax.swing.ButtonGroup buttonGroupQuienReporte;
    private javax.swing.JButton jButtonAgregar;
    private javax.swing.JButton jButtonCerrar;
    private javax.swing.JButton jButtonLimpiar;
    private javax.swing.JCheckBox jCheckBoxNoAsignado;
    private javax.swing.JCheckBox jCheckBoxOtroReporta;
    private javax.swing.JCheckBox jCheckBoxSiAsignado;
    private javax.swing.JCheckBox jCheckBoxYoReporta;
    private javax.swing.JComboBox jComboBoxAsignado;
    private javax.swing.JComboBox jComboBoxPrioridad;
    private javax.swing.JComboBox jComboBoxReporta;
    private javax.swing.JComboBox jComboBoxTipo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabelEstatus;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextAreaDescripcion;
    private javax.swing.JTextField jTextFieldProyecto;
    private javax.swing.JTextField jTextFieldTitulo;
    // End of variables declaration//GEN-END:variables

    private Boolean guiToData() {
        try {
            if (jTextFieldTitulo.getText() == null || jTextFieldTitulo.getText().equals("")) {
                Mensajeria.Mensaje("El username no debe estar vacio");
                return false;
            }


            if (jTextAreaDescripcion.getText().equals("")) {
                Mensajeria.Mensaje("Ingrese la descripcion");
                return false;
            }

            int j = jComboBoxTipo.getSelectedIndex();
            if (j != -1) {
                Tipo t = tipoController.getTipolist().get(j);
                issues.setIdtipo(t.getIdtipo());
            } else {
                Mensajeria.Mensaje("No se ha seleccionado ningun tipo");
                return false;
            }
            j = jComboBoxPrioridad.getSelectedIndex();
            if (j != -1) {
                Prioridad p = prioridadController.getPrioridadlist().get(j);
                issues.setIdprioridad(p.getIdprioridad());
            } else {
                Mensajeria.Mensaje("No se ha seleccionado ninguna prioridad");
                return false;
            }
            if (jCheckBoxNoAsignado.isSelected()) {
                issues.setUsernameasignado("");
            } else {
                int k = jComboBoxAsignado.getSelectedIndex();
                if (k != -1) {

                    Equiposusuarios e = equiposusuariosController.getEquiposusuarioslist().get(k);
                    issues.setUsernameasignado(e.getUsername());
                } else {
                    Mensajeria.Mensaje("No se ha seleccionado ningun tecnico");
                    return false;
                }
            }

            if (jCheckBoxYoReporta.isSelected()) {
                issues.setUsername(MySesion.getUsuarios().getUsername());
            } else {
                j = jComboBoxReporta.getSelectedIndex();
                if (j != -1) {
                    Usuarios u = usuariosController.getUsuarioslist().get(j);
                    issues.setUsername(u.getUsername());
                } else {
                    Mensajeria.Mensaje("No se ha seleccionado usuario que reporta");
                    return false;
                }

            }
            issues.setTitulo(jTextFieldTitulo.getText());
            Integer numero = issuesController.func("max", "numero", "idproyecto='" + MySesion.getProyectos().getIdproyecto() + "'").intValue() + 1;
            issues.setNumero(numero);
            issues.setDescripcion(jTextAreaDescripcion.getText());
            issues.setIdproyecto(MySesion.getProyectos().getIdproyecto());
            issues.setIdestatus(estatus.getIdestatus());
            issues.setFecha(MySesion.getFechausername());

            issues.setHora(MySesion.getHoraSistema());


            return true;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "guiToData()");
        }
        return false;
    }

    private Boolean cargarTipo() {
        try {
            jComboBoxTipo.removeAllItems();
            if (tipoController.selectAll()) {
                for (Tipo t : tipoController.getTipolist()) {
                    jComboBoxTipo.addItem(t.getTipo());
                }
                return true;
            } else {
                Mensajeria.Mensaje("Debe crear primero los tipos");
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarTipo() ");

        }
        return false;
    }

    private Boolean cargarPrioridad() {
        try {
            jComboBoxPrioridad.removeAllItems();
            if (prioridadController.selectAll()) {
                for (Prioridad p : prioridadController.getPrioridadlist()) {
                    jComboBoxPrioridad.addItem(p.getPrioridad());
                }
                return true;
            } else {
                Mensajeria.Mensaje("Debe crear primero las prioridades");
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarPrioridad() ");

        }
        return false;
    }

    private Boolean cargarUsuarios() {
        try {

            jComboBoxAsignado.removeAllItems();
            String sql = "idequipo='" + MySesion.getProyectos().getIdequipo() + "'";
            if (equiposusuariosController.query(sql)) {
                for (Equiposusuarios eu : equiposusuariosController.getEquiposusuarioslist()) {
                    jComboBoxAsignado.addItem(eu.getUsuarios().getNombre() + " - " + eu.getUsuarios().getCedula());
                }
                return true;
            } else {
                Mensajeria.MensajeWarning("No hay usuarios asignados al equipo de este proyecto");
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarUsuarios() ");
        }
        return false;
    }

    private Boolean cargarReporta() {
        try {

            jComboBoxReporta.removeAllItems();
            if (usuariosController.selectAll()) {
                for (Usuarios u : usuariosController.getUsuarioslist()) {
                    jComboBoxReporta.addItem(u.getNombre() + " - " + u.getCedula());
                }
                return true;
            } else {
                Mensajeria.MensajeWarning("No hay usuarios ");
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarReporta()");
        }
        return false;
    }

    private void limpiar() {
        jTextFieldTitulo.setText("");
        jTextAreaDescripcion.setText("");

    }
}
